import Vue from './instance/index'
import { initGlobalAPI } from './global-api/index'
import { isServerRendering } from 'core/util/env'
import { FunctionalRenderContext } from 'core/vdom/create-functional-component'
/**
 * 定义全局的Vue静态方法
 * 1. Vue.set($set)、Vue.delete($delete)、Vue.nextTick($nextTick)
 * 2. 定义并扩展Vue.options对象： Vue.options = { 'components':{}, 'directives': {}, 'filters': {}}, 以及Vue.options._base = Vue。
 *    将内置keep-alive组件挂载到Vue.options.components上。
 * 3. 
 * 
 */
initGlobalAPI(Vue)

Object.defineProperty(Vue.prototype, '$isServer', {
  get: isServerRendering
})

Object.defineProperty(Vue.prototype, '$ssrContext', {
  get () {
    /* istanbul ignore next */
    return this.$vnode && this.$vnode.ssrContext
  }
})

// expose FunctionalRenderContext for ssr runtime helper installation
Object.defineProperty(Vue, 'FunctionalRenderContext', {
  value: FunctionalRenderContext
})

Vue.version = '__VERSION__'

export default Vue
